package aad.storyboard.model;

import java.util.ArrayList;

import aad.storyboard.controller.DragDropManager;

/**
 * Command pattern: will be triggered by the DragDropManager if an ActionDown event is registered for a draggable image
 */
public class ActionDownHelper implements DragDropHelpCommand{
	
	private int X;
	private int Y;	
	
	public ActionDownHelper()	{
		
	}

	@Override
	public void help() {		
        
		Integer key2 = new Integer(AnimationProvider.EVENT_DRAG);
		ArrayList<Animation> dragAnimations = AnimationProvider.getInstance().getOnEventAnimations().get(key2);
        
		for(Animation a : dragAnimations){
			for (Image img:a.getImages())
			if(X>= img.getPosX() && X <= img.getPosX()+img.getWidth()){
				if(Y>= img.getPosY() && Y <= img.getPosY()+img.getHeight()){
					DragDropManager.getInstance().setDraggedImage(img);
    			System.out.println("DraggedImage set");
                break;
    		}		
    		
			}
		}
		
	}

	@Override
	public void setX(int x) {
		X=x;
		
	}

	@Override
	public void setY(int y) {
		Y=y;
		
	}

}
